//package com.np.javacv1;
//
//import java.io.IOException;
//
//import org.bytedeco.javacv.*;
//import org.bytedeco.ffmpeg.global.avcodec;
//import org.bytedeco.ffmpeg.global.avformat;
//import org.bytedeco.ffmpeg.global.avutil;
//
//public class RtmpPublisher {
//    private static final String RTMP_URL = "rtmp://localhost:1935/live";
//    private static final int WIDTH = 640;
//    private static final int HEIGHT = 480;
//    private static final int FPS = 30;
//    private static final int BITRATE = 800000;
//    private static final boolean HARDWARE_ACCELERATION = true;
//    private static final boolean DEBUG = false;
//
//    public static void main(String[] args) throws IOException, InterruptedException {
//        FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(WIDTH, HEIGHT, FPS);
//        grabber.start();
//        FrameRecorder recorder = new FFmpegFrameRecorder(RTMP_URL, WIDTH, HEIGHT, FPS, BITRATE, HARDWARE_ACCELERATION, DEBUG);
//        recorder.setVideoCodec(avcodec.AV_CODEC_ID_H264);
//        recorder.setFormat("flv");
//        recorder.setPixelFormat(avutil.AV_PIX_FMT_YUV420P);
//        recorder.setGopSize(15);
//        recorder.setVideoBitrate(BITRATE);
//        recorder.setVideoOption("preset", "ultrafast");
//        recorder.setVideoOption("tune", "zerolatency");
//        recorder.setVideoOption("crf", "28");
//        recorder.setAudioOption("b", "128k");
//        recorder.setAudioOption("ac", "2");
//        recorder.setAudioOption("ar", "44100");
//        recorder.setAudioOption("channels", "1");
//        recorder.setAudioOption("codec:a", "aac");
//        recorder.setAudioOption("strict", "-2");
//        recorder.start();
//        Frame frame;
//        while ((frame = grabber.grab()) != null) {
//            recorder.record(frame);
//        }
//        grabber.stop();
//        recorder.stop();
//    }
//}